<?php
/*
 *author:Yangligao
 *Date:2013-9-24
 */
require 'Config.php';
$flag = $_GET['flag'];

if($flag == 'display'){
	
	$smarty->display("Index/pwdfind.html");
	
}else if($flag == 'deal'){
	
	$userModel = new UserModel();
	
	
	$userName = $_POST['user_name'];
	$question = $_POST['user_pwdquestion'];
	$answer = $_POST['user_pwdanswer'];
	
	$res = $userModel->user_select($userName,"*");
	if(count($res) != 0){
		if((@$question == $res[0]['user_pwdquestion']) && (@$answer == $res[0]['user_pwdanswer'])){
			
			$userBackModel = new UserBackModel();
			@$pwdRes = $userBackModel->user_back_select("where user_id=".$res[0]['user_id']);
			
	
			if(count($pwdRes) != 0){
				$smarty->assign("passflag",1);
				$smarty->assign("pwd",$pwdRes[0]['user_pwd']);
				$smarty->display("Index/pwdfind.html");
			}
		}
	}else{
		echo "<script type='text/javascript'>alert('请填写相关信息！');</script>";
		header("Location:PwdFind.php?flag=display");
	}
}

?>
